﻿using System;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel.Design;
using System.Collections.Generic;
using System.ComponentModel;
namespace OpenComposite.EII.Repository
{
	public interface IRepositoryItem : IServiceProvider, IComponent
	{
		/// <summary>
		/// Gets the ID.
		/// </summary>
		/// <value>The ID.</value>
		int ID { get; }
		/// <summary>
		/// Gets or sets the name.
		/// </summary>
		/// <value>The name.</value>
		string Name { get; set; }
		/// <summary>
		/// Gets or sets the description.
		/// </summary>
		/// <value>The description.</value>
		string Description { get; set; }
		/// <summary>
		/// Gets or sets the N text.
		/// </summary>
		/// <value>The N text.</value>
		string NText { get; set; }

		/// <summary>
		/// Gets the image key.
		/// </summary>
		/// <value>The image key.</value>
		string ImageKey { get; }
		/// <summary>
		/// Gets the selected image key.
		/// </summary>
		/// <value>The selected image key.</value>
		string SelectedImageKey { get; }
		/// <summary>
		/// Gets the image.
		/// </summary>
		/// <value>The image.</value>
		Image Image { get; }
		/// <summary>
		/// Gets the selected image.
		/// </summary>
		/// <value>The selected image.</value>
		Image SelectedImage { get; }

		//DesignerVerbCollection Verbs { get; }

		/// <summary>
		/// Gets the display text.
		/// </summary>
		/// <value>The display text.</value>
		string Display { get; }

		/// <summary>
		/// Gets the type of the repository item.
		/// </summary>
		/// <value>The type of the repository item.</value>
		ItemType RepositoryItemType { get; }
		/// <summary>
		/// Gets the name of the repository item type.
		/// </summary>
		/// <value>The name of the repository item type.</value>
		string RepositoryItemTypeName { get; }
		/// <summary>
		/// Gets the repository item type description.
		/// </summary>
		/// <value>The repository item type description.</value>
		string RepositoryItemTypeDescription { get; }

		/// <summary>
		/// Gets a value indicating whether [allow drop].
		/// </summary>
		/// <value><c>true</c> if [allow drop]; otherwise, <c>false</c>.</value>
		bool AllowDrop { get; }
		/// <summary>
		/// Gets the allowed child types.
		/// </summary>
		/// <value>The allowed child types.</value>
		List<ItemType> AllowedChildTypes { get; }

		/// <summary>
		/// Occurs when [item changing].
		/// </summary>
		event Services.RepositoryChangingEventHandler ItemChanging;
		/// <summary>
		/// Occurs when [item changed].
		/// </summary>
		event Services.RepositoryChangedEventHandler ItemChanged;
		/// <summary>
		/// Occurs when [item deleting].
		/// </summary>
		event Services.RepositoryEventHandler ItemDeleting;
		/// <summary>
		/// Occurs when [item deleted].
		/// </summary>
		event Services.RepositoryEventHandler ItemDeleted;

		/// <summary>
		/// Initializes the service provider.
		/// </summary>
		/// <param name="serviceProvider">The service provider.</param>
		void InitializeServiceProvider(IServiceProvider serviceProvider);
		/// <summary>
		/// Sets the ID and name.
		/// </summary>
		/// <param name="id">The ID.</param>
		/// <param name="name">The name.</param>
		void SetIdAndName(int id, string name);

		/// <summary>
		/// Loads the item with the specified ID.
		/// </summary>
		/// <param name="id">The ID.</param>
		/// <returns></returns>
		bool Load(int id);
		/// <summary>
		/// Reloads this instance.
		/// </summary>
		/// <returns></returns>
		bool Reload();
		/// <summary>
		/// Saves this instance.
		/// </summary>
		/// <returns></returns>
		bool Save();
		/// <summary>
		/// Deletes this instance.
		/// </summary>
		/// <param name="bAsk">if set to <c>true</c> show a message to ask for deleting.</param>
		/// <returns></returns>
		bool Delete(bool bAsk);
		/// <summary>
		/// Creates a new item.
		/// </summary>
		/// <returns>Returns <c>true</c> if item was successfully created.</returns>
		bool CreateNew();
		/// <summary>
		/// Copies this instance.
		/// </summary>
		/// <param name="deep"><c>true</c> to recursively copy the item and all subitems; 
		/// <c>false</c> to copy only the item itself.</param>
		/// <returns>The copied item.</returns>
		IRepositoryItem Copy(bool deep);

		/// <summary>
		/// Begins the edit.
		/// </summary>
		/// <returns></returns>
		bool BeginEdit();
		/// <summary>
		/// Cancels the edit.
		/// </summary>
		/// <returns></returns>
		bool CancelEdit();
		/// <summary>
		/// Ends the edit.
		/// </summary>
		/// <param name="bSave">if set to <c>true</c> save this instance.</param>
		/// <returns></returns>
		bool EndEdit(bool bSave);

		/// <summary>
		/// Gets the icon.
		/// </summary>
		/// <returns></returns>
		Icon GetIcon();

		/// <summary>
		/// Determines whether the given name is still available in this domain for the type of this item.
		/// </summary>
		/// <param name="newName">The new name.</param>
		/// <returns>
		/// 	<c>true</c> if name is available; otherwise, <c>false</c>.
		/// </returns>
		bool IsNameAvailable(string newName);

		/// <summary>
		/// Sets the drag drop data object.
		/// </summary>
		/// <param name="dataObj">The data object.</param>
		void SetDragDropDataObject(IDataObject dataObj);

		/// <summary>
		/// Shows the new item form.
		/// </summary>
		/// <param name="idRepository">The repository ID.</param>
		/// <param name="bAllowContinue">if set to <c>true</c> to allow save and continue.</param>
		/// <param name="parentItem">The parent item.</param>
		/// <param name="idDomain">The domain ID.</param>
		/// <param name="parentItemNew">The new parent item.</param>
		/// <returns></returns>
		DialogResult ShowNewItemForm(int idRepository, bool bAllowContinue,
									 IRepositoryItem parentItem,
									 ref int idDomain, out IRepositoryItem parentItemNew);
	}
}
